﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <el-form ref="formRefEquipmentSpotTable" :model="stateEquipmentSpotTable.vmModel" label-width="100px">
    <div style="margin-bottom:10px;">{{$t('message.autotrans.SysBatchEditConfirm')}}</div>
    <el-row>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_EquipmentId_FormItem" prop="LinkedVM.EquipmentId" :label="$t('message.autotrans._Model_EquipmentSpotTable_Equipment')">
          <el-select v-model="stateEquipmentSpotTable.vmModel.LinkedVM.EquipmentId" clearable>
             <el-option v-for="item in stateEquipmentSpotTable.AllEquipments" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_LineId_FormItem" prop="LinkedVM.LineId" :label="$t('message.autotrans._Model_EquipmentSpotTable_LineId')">
          <el-input v-model="stateEquipmentSpotTable.vmModel.LinkedVM.LineId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_LineCode_FormItem" prop="LinkedVM.LineCode" :label="$t('message.autotrans._Model_EquipmentSpotTable_LineCode')">
          <el-input v-model="stateEquipmentSpotTable.vmModel.LinkedVM.LineCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_OpId_FormItem" prop="LinkedVM.OpId" :label="$t('message.autotrans._Model_EquipmentSpotTable_OpId')">
          <el-input v-model="stateEquipmentSpotTable.vmModel.LinkedVM.OpId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_OpCode_FormItem" prop="LinkedVM.OpCode" :label="$t('message.autotrans._Model_EquipmentSpotTable_OpCode')">
          <el-input v-model="stateEquipmentSpotTable.vmModel.LinkedVM.OpCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_UseOperator_FormItem" prop="LinkedVM.UseOperator" :label="$t('message.autotrans._Model_EquipmentSpotTable_UseOperator')">
          <el-input v-model="stateEquipmentSpotTable.vmModel.LinkedVM.UseOperator" clearable></el-input>
      </el-form-item>

      </el-col>
    </el-row>

    <div style="text-align:right;">
      <WtmButton @click="onSubmitEquipmentSpotTable"  type="primary" :button-text="$t('message.autotrans.SysSubmit')" style="margin-top:15px;"/>

      <WtmButton @click="onCloseEquipmentSpotTable"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

    </div>

  </el-form>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageEquipmentManagementEquipmentSpotTableBatchEdit;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { equipmentspottableApi } from '/@/api/equipmentmanagement/equipmentspottable';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefEquipmentSpotTable = ref();
const stateEquipmentSpotTable = reactive({
    vmModel: {
	  LinkedVM:{
        EquipmentId: null,
        LineCode: '',
        OpCode: '',
        UseOperator: '',
      },
      Ids:[],
      
	},
    
    AllEquipments: [] as any[],
});

// 取消
const onCloseEquipmentSpotTable = () => {
    closeDialog();
};

// 提交
const onSubmitEquipmentSpotTable = () => {
	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});

    formRefEquipmentSpotTable.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            equipmentspottableApi().batchedit(stateEquipmentSpotTable.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error:any) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};


// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/EquipmentManagement/EquipmentSpotTable/GetEquipments',[],false).then(x=>{stateEquipmentSpotTable.AllEquipments = x});
    if (ci.attrs["wtmdata"]) {
		stateEquipmentSpotTable.vmModel.Ids = ci.attrs["wtmdata"];
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateEquipmentSpotTable.vmModel.Ids = useRouter().currentRoute.value.query.id as any;
	}

});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

